
<div id="menu">
    <ul class="menu">
        <?php
        $main_menu = array('news', 'products', 'entertainment', 'contact');
        $current = $this->uri->segment(2);
        for ($i = 0; $i < count($main_menu); $i++) {
            $this->db->select('*');
            $this->db->from('tbl_menu');
            $this->db->where('menu_type', $main_menu[$i]);
            $sub_menu = $this->db->get();
            if ($sub_menu->num_rows() > 0) {
                // in case there are sub menus
                if ($main_menu[$i] == $current) {
                    echo '<li class="current">' . anchor(site_url('pages/' . $main_menu[$i]), '<span>' . $main_menu[$i] . '</span>', array('class' => 'parent'));
                } else {
                    echo '<li>' . anchor(site_url('pages/' . $main_menu[$i]), '<span>' . $main_menu[$i] . '</span>', array('class' => 'parent'));
                }
                echo '<div><ul>';
                foreach ($sub_menu->result() as $rows) {
					if($rows->menu_statu_id==1){
                    echo '<li>' . anchor(site_url().$rows->menu_link, '<span>' . $rows->menu_title . '</span>') . '</li>';
					}
                }
                echo '</ul></div></li>';
            } else {
                // in case there is no sub menu
                if ($main_menu[$i] == $current) {
                    echo '<li class="current">' . anchor(site_url('pages/' . $main_menu[$i]), '<span>' . $main_menu[$i] . '</span>') . '</li>';
                } else {
                    echo '<li>' . anchor(site_url('pages/' . $main_menu[$i]), '<span>' . $main_menu[$i] . '</span>') . '</li>';
                }
            }
        }
        ?>
    </ul>
</div>